package com.ymatou.iapi.email.testcase;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.ymatou.iapi.email.parameter.SendTemplateEmailBean;
import com.ymatou.iapi.email.service.SendTemplateEmailCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.MailContent;
import com.ymttest.database.model.MailRecord;
import com.ymttest.database.sqlwapper.EmailWapper;
import com.ymttest.utils.TestDataManager;
/**
*发送模板邮件
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_SendTemplateEmail{
	private static SendTemplateEmailBean sendtemplateemailBean;
	private static SendTemplateEmailCall sendtemplateemailCall;
	private static EmailWapper emailwapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("发送模板邮件");
	}

	@Before
	public void caseUp() {
		sendtemplateemailBean=new SendTemplateEmailBean();
		sendtemplateemailCall=new SendTemplateEmailCall();
		emailwapper=new EmailWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(sendtemplateemailCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_SendTemplateEmail_001() {
		Logger.start(true,"发送模板邮件成功");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendTemplateEmail_002() {
		Logger.start(true,"发送多个模板邮件成功");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com;zhangxiaoming@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");

			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");

			String[] tomails = sendtemplateemailBean.getToMail().split(";");
			Logger.verifyEquals(tomails.length, idList.size(), "验证条数");

			List<String> mtomails = new ArrayList<String>();
			for (String string : tomails) {
				mtomails.add(string);
			}

			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");

				Logger.verifyEquals(true, mtomails.contains(record.getToMail()), "验证ToMail");
				mtomails.remove(sendtemplateemailBean.getToMail());
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendTemplateEmail_003() {
		Logger.start(true,"发送超过50个模板邮件失败");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			String tomail="";
			for (int i = 0; i <51; i++) {
				tomail=tomail+TestDataManager.getRandomUUID().toString()+"@ymatou.com;";
			}
			sendtemplateemailBean.setToMail(tomail);
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyIsContains("一次发送的邮件数不能超过50个", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("false", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("3", sendtemplateemailCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	@Ignore
	//可以成功
	public void Tc_SendTemplateEmail_004() {
		Logger.start(true,"不输入appid失败");
		try {
//			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyIsContains("appId:may not be null", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("false", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("2", sendtemplateemailCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendTemplateEmail_005() {
		Logger.start(true,"不输入mailTemplateId失败");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
//			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyIsContains("mailTemplateId:may not be empty", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("false", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("2", sendtemplateemailCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendTemplateEmail_006() {
		Logger.start(true,"输入错误mailTemplateId失败");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("TestTemplated1");
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyIsContains("不存在", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("false", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("3", sendtemplateemailCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendTemplateEmail_007() {
		Logger.start(true,"不输入fromMail失败");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
//			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyIsContains("fromMail:may not be null", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("false", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("2", sendtemplateemailCall.getString("errorCode"), "验证errorCode");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendTemplateEmail_008() {
		Logger.start(true,"不输入fromName,成功,使用系统配置fromname");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
//			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_SendTemplateEmail_009() {
		Logger.start(true,"不输入toMail失败");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("alarm@ymatou.com");
			sendtemplateemailBean.setFromName("邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("TestTemplated");
			Map parameters=new HashMap<>();
			parameters.put("name", "test value");
			sendtemplateemailBean.setParameters(parameters);
//			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyIsContains("toMail:may not be null", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("false", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("2", sendtemplateemailCall.getString("errorCode"), "验证errorCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_010() {
		Logger.start(true, "webpower发送邮件成功");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("webpower");
			sendtemplateemailBean.setFromName("webpower邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("AccountSecurityValidate");
			//{"email":"isdoudou@163.com","validatecode":"803667","sendtime":"09/15/2017"}
			Map parameters=new HashMap<>();
			parameters.put("email", "zhouyi@ymatou.com");
			parameters.put("validatecode", "999999");
			parameters.put("sendtime", "09/15/2017");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");
				//20171124 webpower不用了 邮件都走sendcloud
				Logger.verifyEquals(record.getFromMail(), "sendcloud", "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_011() {
		Logger.start(true, "sendcloud发送邮件成功AccountSecurityValidate");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("AccountSecurityValidate");
			//{"email":"isdoudou@163.com","validatecode":"803667","sendtime":"09/15/2017"}
			Map parameters=new HashMap<>();
			parameters.put("email", "zhouyi@ymatou.com");
			parameters.put("validatecode", "888888");
			parameters.put("sendtime", "09/15/2017");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_012() {
		Logger.start(true, "sendcloud发送邮件成功ActiveSeller");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("ActiveSeller");
			//{"loginid":"马来跟我一样美","currentyear":"2017","sendtime":"2017-09-14 04:38:48","unpassreason":null,"passtime":"2017-09-14"}
			Map parameters=new HashMap<>();
			parameters.put("loginid", "zhouyi@ymatou.com");
			parameters.put("unpassreason", null);
			parameters.put("currentyear", "2017");
			parameters.put("sendtime", "2017-09-14 04:38:48");
			parameters.put("passtime", "2017-09-14");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	AppEmailVerifyCodeTemplate
//	{"validatecode":"8c0a"}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_013() {
		Logger.start(true, "sendcloud发送邮件成功AppEmailVerifyCodeTemplate");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("AppEmailVerifyCodeTemplate");
			//{"loginid":"马来跟我一样美","currentyear":"2017","sendtime":"2017-09-14 04:38:48","unpassreason":null,"passtime":"2017-09-14"}
			Map parameters=new HashMap<>();
			parameters.put("validatecode", "auto");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//
//	BuyerRegistSuccess
//	{"loginid":"美淘美购_sx1","loginemail":"510758957@qq.com","validateurl":"http://sellerregister.ymatou.com/base/Register?confirmation=CfHEuC%2FXRnyY4jQoJ02R2Ivkpn3MiCpERqOzIKYfYaZsl5niQPAJSlo2JmaCxnkM6k%2FQM9Wo9kvNF%2BOowi1WtESjiVUlOVGEDRi90tieyJSCQRnPvzw7nkaaXGSM9GGKQkoT85KXenJ4qt5EiYyJigNwxOCI8zEh7gwEqQf10Wk%3D"}
//
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_014() {
		Logger.start(true, "sendcloud发送邮件成功BuyerRegistSuccess");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("BuyerRegistSuccess");
//			{"loginid":"美淘美购_sx1","loginemail":"510758957@qq.com","validateurl":"http://sellerregister.ymatou.com/base/Register?confirmation=CfHEuC%2FXRnyY4jQoJ02R2Ivkpn3MiCpERqOzIKYfYaZsl5niQPAJSlo2JmaCxnkM6k%2FQM9Wo9kvNF%2BOowi1WtESjiVUlOVGEDRi90tieyJSCQRnPvzw7nkaaXGSM9GGKQkoT85KXenJ4qt5EiYyJigNwxOCI8zEh7gwEqQf10Wk%3D"}
			Map parameters=new HashMap<>();
			parameters.put("loginid", "auto");
			parameters.put("loginemail", "zhouyi@ymatou.com");
			parameters.put("validateurl", "http://sellerregister.ymatou.com/base/Register?confirmation=CfHEuC%2FXRnyY4jQoJ02R2Ivkpn3MiCpERqOzIKYfYaZsl5niQPAJSlo2JmaCxnkM6k%2FQM9Wo9kvNF%2BOowi1WtESjiVUlOVGEDRi90tieyJSCQRnPvzw7nkaaXGSM9GGKQkoT85KXenJ4qt5EiYyJigNwxOCI8zEh7gwEqQf10Wk%3D");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	PassCompanySeller
//	{"loginid":"美味日记","currentyear":"2017","sendtime":"2017-09-15 02:57:15","unpassreason":null,"passtime":"2017-09-15"}
//
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_015() {
		Logger.start(true, "sendcloud发送邮件成功PassCompanySeller");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("PassCompanySeller");
//			{"loginid":"美淘美购_sx1","loginemail":"510758957@qq.com","validateurl":"http://sellerregister.ymatou.com/base/Register?confirmation=CfHEuC%2FXRnyY4jQoJ02R2Ivkpn3MiCpERqOzIKYfYaZsl5niQPAJSlo2JmaCxnkM6k%2FQM9Wo9kvNF%2BOowi1WtESjiVUlOVGEDRi90tieyJSCQRnPvzw7nkaaXGSM9GGKQkoT85KXenJ4qt5EiYyJigNwxOCI8zEh7gwEqQf10Wk%3D"}
			Map parameters=new HashMap<>();
			parameters.put("loginid", "zhouyi@ymatou.com");
			parameters.put("unpassreason", null);
			parameters.put("currentyear", "2017");
			parameters.put("sendtime", "2017-09-14 04:38:48");
			parameters.put("passtime", "2017-09-14");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	PassPersonalSeller
//	{"loginid":"咖啡豆cafe","currentyear":"2017","sendtime":"2017-09-15 04:50:18","unpassreason":null,"passtime":"2017-09-15"}
//
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_016() {
		Logger.start(true, "sendcloud发送邮件成功PassPersonalSeller");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("PassPersonalSeller");
//			{"loginid":"美淘美购_sx1","loginemail":"510758957@qq.com","validateurl":"http://sellerregister.ymatou.com/base/Register?confirmation=CfHEuC%2FXRnyY4jQoJ02R2Ivkpn3MiCpERqOzIKYfYaZsl5niQPAJSlo2JmaCxnkM6k%2FQM9Wo9kvNF%2BOowi1WtESjiVUlOVGEDRi90tieyJSCQRnPvzw7nkaaXGSM9GGKQkoT85KXenJ4qt5EiYyJigNwxOCI8zEh7gwEqQf10Wk%3D"}
			Map parameters=new HashMap<>();
			parameters.put("loginid", "zhouyi@ymatou.com");
			parameters.put("unpassreason", null);
			parameters.put("currentyear", "2017");
			parameters.put("sendtime", "2017-09-14 04:38:48");
			parameters.put("passtime", "2017-09-14");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	RejectSeller
//	{"loginid":"竹子在法国","currentyear":"2017","sendtime":"2017-09-15 05:09:44","unpassreason":"身份证件的有效期不在3个月以上;","passtime":"2017-09-15"}
//
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_017() {
		Logger.start(true, "sendcloud发送邮件成功RejectSeller");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("RejectSeller");
//			{"loginid":"美淘美购_sx1","loginemail":"510758957@qq.com","validateurl":"http://sellerregister.ymatou.com/base/Register?confirmation=CfHEuC%2FXRnyY4jQoJ02R2Ivkpn3MiCpERqOzIKYfYaZsl5niQPAJSlo2JmaCxnkM6k%2FQM9Wo9kvNF%2BOowi1WtESjiVUlOVGEDRi90tieyJSCQRnPvzw7nkaaXGSM9GGKQkoT85KXenJ4qt5EiYyJigNwxOCI8zEh7gwEqQf10Wk%3D"}
			Map parameters=new HashMap<>();
			parameters.put("loginid", "zhouyi@ymatou.com");
			parameters.put("unpassreason", "身份证件的有效期不在3个月以上;");
			parameters.put("currentyear", "2017");
			parameters.put("sendtime", "2017-09-14 04:38:48");
			parameters.put("passtime", "2017-09-14");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
//	SellerForgetPassWord
//	{"loginid":"www_net77","amendurl":"http://slogin.ymatou.com/ForgetPwd/EmailLinkActive?confirmation=97CBA71F-CE61-4C92-A927-057616497656&email=ooeanpeter@gmail.com"}
	@Test
	@Category({ P1.class })
	@TestCase
	public void Tc_SendEmail_018() {
		Logger.start(true, "sendcloud发送邮件成功RejectSeller");
		try {
			sendtemplateemailBean.setAppId("AutoTest");
			// 测试账号 配置在mail_sender 表中
			sendtemplateemailBean.setFromMail("sendcloud");
			sendtemplateemailBean.setFromName("sendcloud邮件测试AutoTest");
			//测试使用固定TestTemplated  mail_template表中可获取
			sendtemplateemailBean.setMailTemplateId("SellerForgetPassWord");
//			{"loginid":"美淘美购_sx1","loginemail":"510758957@qq.com","validateurl":"http://sellerregister.ymatou.com/base/Register?confirmation=CfHEuC%2FXRnyY4jQoJ02R2Ivkpn3MiCpERqOzIKYfYaZsl5niQPAJSlo2JmaCxnkM6k%2FQM9Wo9kvNF%2BOowi1WtESjiVUlOVGEDRi90tieyJSCQRnPvzw7nkaaXGSM9GGKQkoT85KXenJ4qt5EiYyJigNwxOCI8zEh7gwEqQf10Wk%3D"}
			Map parameters=new HashMap<>();
			parameters.put("loginid", "zhouyi@ymatou.com");
			parameters.put("amendurl", "http://slogin.ymatou.com/ForgetPwd/EmailLinkActive?confirmation=97CBA71F-CE61-4C92-A927-057616497656&email=TEST@gmail.com");
			sendtemplateemailBean.setParameters(parameters);
			sendtemplateemailBean.setToMail("zhouyi@ymatou.com");
			sendtemplateemailCall.setData(sendtemplateemailBean);
			sendtemplateemailCall.callService();
			Logger.verifyEquals("success", sendtemplateemailCall.getString("errorMessage"), "验证errorMessage");
			Logger.verifyEquals("true", sendtemplateemailCall.getString("success"), "验证success");
			Logger.verifyEquals("0", sendtemplateemailCall.getString("errorCode"), "验证errorCode");

			JsonArray idList = sendtemplateemailCall.getJsonObject().getAsJsonObject("result").getAsJsonArray("idList");
			Logger.verifyEquals(1, idList.size(), "验证条数");
			Logger.verifyNotNull(sendtemplateemailCall.getJsonObject().getAsJsonObject("result").get("batchId").getAsString(), "验证batchId");
			for (JsonElement je : idList) {
				MailRecord record = emailwapper.selectMailRecordById(je.getAsString()).get(0);
				Logger.verifyEquals(record.getAppId(), sendtemplateemailBean.getAppId(), "验证appid");

				Logger.verifyEquals(record.getFromMail(), sendtemplateemailBean.getFromMail(), "验证frommail");
				Logger.verifyEquals(record.getToMail(), sendtemplateemailBean.getToMail(), "验证ToMail");
				Logger.verifyEquals(record.getMailTemplateId(),sendtemplateemailBean.getMailTemplateId(), "验证MailTemplateId");
				// 0 ready 1 success
				Logger.verifyEquals(true, record.getStatus() == 0 || record.getStatus() == 1, "验证Status为0或1");
			}
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}